<template>
  <el-menu
    default-active="1"
    class="el-menu-vertical-demo"
    background-color="#324157"
    text-color="#ffff"
    active-text-color="#409EFF">
    <template v-for="(item) in navItem">
    <el-menu-item index="item.ide" @click="jump(item.path)" v-if="item.type==type">
      <i :class="item.icon"></i>
      <span slot="title">{{item.title}}</span>
    </el-menu-item>
    </template>
  </el-menu>

</template>

<script>
    import navItems from "../../common/NavItem";

    export default {
        name: "Nav",
        data(){
            return{
              type:0,
              navItem:[]
            }
        },
        methods:{
          jump(path){
            this.$router.push({
              name:path
            })
          }
        },
        mounted(){
          this.navItem = navItems;

          let user = this.$store.getters.getUser;
          if (user.username !=null && user.username !=""){
            this.type = user.type;
          }else {
            this.$notify.error({
              title: '错误',
              message: '未登录，2秒后跳转回首页',
              duration:2000
            });
            setTimeout(()=>{
              this.$router.replace("/")
            },1800);
          }
        }

    }
</script>

<style scoped>

</style>
